package com.atguigu.gmall.realtime.utils

import java.io.{FileInputStream, Reader}
import java.util.{Properties, ResourceBundle}

import scala.io.{BufferedSource, Source}


object MyPropsUtil {
  /**
   * 配置文件解析类
   */

  def main(args: Array[String]): Unit = {
    /*
    *获取配置文件的信息，方式一
     */

 /*   val properties: Properties = new Properties()
    val path = Thread.currentThread().getContextClassLoader.getResource("config.properties").getPath
    println(path)
    properties.load(new FileInputStream(path))
    val str: String = properties.getProperty("kafka.servers")
    println(str)*/
//方式二：
    println(MyPropsUtil("bootstrap.servers"))

  }
  /*
*获取配置文件的信息，方式二
 */
  private val bundle: ResourceBundle = ResourceBundle.getBundle("config")

  def apply(key : String ) : String = {
    bundle.getString(key)
  }
}
